#include <iostream>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

// 1--A,1--B, 找两个数 x y 使得 x/y==a/b

int gcd(int x ,int y){
    return y?gcd(y,x%y):x;
}

void solve(int A,int B,int a , int b){
    int t=gcd(a,b);
    a=a/t;
    b=b/t;
    //提前处理 1的情况
    if(a==1){
        int i=0;
        for(i=A;i>=1 && b*i>B;i--);
        cout << i << " " << b*i <<endl;
        return ;
    }else if(b==1){
        int i=0;
        for(i=B;i>=1 && a*i>A;i--);
        cout << a*i << " " << i <<endl;
        return ;
    }
    
    int x=0,y=0;
    x=log(A)/log(a);
    y=log(B)/log(b);
    x=pow(a,x);
    y=pow(b,y); //找的是<= A/B 那个最大，非无用
    int tx=A/x;
    int ty=B/y;
    for(;tx>=0;tx--){
        int num=(tx*x/a)*b;
        if(num!=0&&num<=B){
            cout << tx*x << " " << num << endl;
            return;
        }
    }
    for(;ty>=0;ty--){
        int num=(ty*y/b)*a;
        if(num!=0&&num<=A){
            cout << num << " " << ty*y <<endl;
            return ;
        }
    }


    cout << 0 << " " << 0 << endl;
}
int main(){
    freopen("in.txt","r",stdin);
    int A,B,a,b;
    while(cin >> A >> B >> a >>b){
        solve(A,B,a,b);
    }

    return 0;
}